package com.tusuo.stds.rest;

import com.tusuo.stds.util.DESedeUtil;

import org.parceler.Parcel;

import java.util.List;

/**
 * @author J.Huang
 * @version 1.0
 *
 */

@Parcel
public class Question extends ApiResult {
    public int Id;  // 关卡题目Id
    public String Code;
    public int QuestionType;
    public String Text; // 加密的题目内容
    public int IsCorrect;   // 查看记录时，标记用户的选项: 0 未作答 1正确 2错误
    public String Answer;
    public List<QuestionOption> QuestionOptionList;
    public String AnswerContent;
    public String QuestionAnalysis; // 加密的题目解析
    public int CorrectCount;    // 正确次数
    public int WrongCount;      // 错误次数

    public String getDecodedText(String key) {
        return DESedeUtil.decodeValue(key, Text);
    }

    public String getDecodedQuestionAnalysis(String key) {
        return DESedeUtil.decodeValue(key, QuestionAnalysis);
    }

    @Parcel
    public static class QuestionOption {

        public String Id;  // 选项id
        public String Content;
        public boolean IsRight; // 闯关时，标记选项是否正确

        public String getDecodedContent(String key) {
            return DESedeUtil.decodeValue(key, Content);
        }

        @Override
        public String toString() {
            return "QuestionOption{" +
                    "Id='" + Id + '\'' +
                    ", Content='" + Content + '\'' +
                    ", IsRight=" + IsRight +
                    '}';
        }
    }

    @Override
    public String toString() {
        return "Question{" +
                "Id=" + Id +
                ", Code='" + Code + '\'' +
                ", QuestionType=" + QuestionType +
                ", Text='" + Text + '\'' +
                ", Answer='" + Answer + '\'' +
                ", QuestionOptionList=" + QuestionOptionList +
                ", AnswerContent='" + AnswerContent + '\'' +
                ", QuestionAnalysis='" + QuestionAnalysis + '\'' +
                '}';
    }
}
